<!-- inc:header -->
<div class="notice"><div class="p">
	<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td width="150px"><span class="lead">&nbsp;&raquo; 附件列表</span></td>
		<td>
			<table>
			<form method="post" action="{:site_url('files')}">
			<tr>
				<td>附件搜索：</td>
				<td>
					<select name="type" id="type">
						<option value="">全部，不限</option>
						<option value="img"{if($input_type == "img")} selected{end}>图片类</option>
						<option value="video"{if($input_type == "video")} selected{end}>影音类</option>
						<option value="download"{if($input_type == "download")} selected{end}>其他</option>
					</select>
				</td>
				<td>上传时间：</td>
				<td><input type="text" name="postdate" id="postdate" onfocus="show_date('postdate')" style="width:75px;" value="{:$postdate}"></td>
				<td>&nbsp; 关键字：</td>
				<td><input type="text" name="keywords" value="{:$keywords}" id="keywords"></td>
				<td><input type="submit" value="搜索" class="button"></td>
			</tr>
			</form>
			</table>
		</td>
	</tr>
	</table>
</div></div>

<script type="text/javascript" src="js/php.js" /></script>
<div class="main">
<table width="100%" style="layout:fixed;" cellpadding="0" cellspacing="0">
<tr>
	<td class="t_sub" width="50%">名称</td>
	<td class="t_sub" width="50%">名称</td>
</tr>
<tr>
	<!-- $rslist AS $key=>$value -->
	<!-- run:$ftype = ROOT."images/filetype-large/".$value[ftype].".jpg" -->
	<!-- run:$thumb = file_exists($ftype) ? $value[ftype] : "unknown" -->
	<td class="{:($key+1)%2=='' ? 'tc_left' : 'tc_right'}">
		<table width="100%" onMouseOver="over_tr(this)" onMouseOut="out_tr(this)">
		<tr>
			<td align="center" width="90px" height="90px">
				<div style="position:relative;z-index:1;"><a href="javascript:phpjs_preview({:$value[id]});void(0);"><!-- if($value[thumb]) --><img src="{:$value[thumb]}" width="80px" height="80px" /><!-- else --><img src="images/filetype-large/{:$thumb}.jpg" width="80px" height="80px" /><!-- end --></a>
					<div style="position:absolute;z-index:2;top:0px;left:5px;"><input type="checkbox" value="{:$value[id]}" /> </div>
				</div>
			</td>
			<td>
				<div style="display:none;"><form method="post" action="#" onsubmit="update_name({:$value[id]});return false;"></div>
				<div><input type="text" id="tmpname_{:$value[id]}" value="{:$value[title] ? $value[title] : basename($value[filename])}" style="width:230px" /> <input type="submit" value="改名" /></div>
				<div style="display:none;"></form></div>
				<div style="padding-top:5px;">上传时间：{:date("Y-m-d H:i:s",$value[postdate])}</div>
				<div style="padding-top:5px;">
					<input type="button" onclick="update_one({:$value[id]})" value="更新" /> &nbsp;
					<input type="button" onclick="phpjs_preview({:$value[id]})" value="预览" /> &nbsp;
					<input type="button" onclick="to_delete({:$value[id]})" value="删除" /> &nbsp;
					<span id="notice_{:$value[id]}" style="color:darkblue;"></span>
				</div>
			</td>
		</tr>
		</table>
	</td>
	<!-- row:2 -->
	<!-- end -->
</tr>
</table>
</div>
<div class="table">
	<table width="100%">
	<tr>
		<td>
			<input type="button" value="全选" onclick="select_all()">
			<input type="button" value="全不选" onclick="select_none()">
			<input type="button" value="反选" onclick="select_anti()">
			&nbsp;
			<input type="button" value="批量更新" onclick="update_pl()">
			<input type="button" value="全部更新" onclick="update_all()">
			&nbsp;
			<input type="button" value="批量删除" onclick="del_pl()">
		</td>
		<td align="right">{:$pagelist}</td>
	</tr>
	</table>
</div>
<script type="text/javascript">
function update_one(id)
{
	var url = base_file + "?" + base_ctrl + "=open&" + base_func + "=pl&picid="+id;
	Layer.init(url,630,500);
}
function update_pl()
{
	var id = join_checkbox();
	if(!id)
	{
		alert("请选择要更新的附件");
		return false;
	}
	var url = base_file + "?" + base_ctrl + "=open&" + base_func + "=pl&picid="+id;
	Layer.init(url,630,500);
}
function update_all()
{
	var url = base_file + "?" + base_ctrl + "=open&" + base_func + "=pl&picid=all";
	Layer.init(url,630,500);
}
function del_pl()
{
	var id = join_checkbox();
	if(!id)
	{
		alert("请选择要批量删除的附件");
		return false;
	}
	var qc = confirm("确定要删除这些附件吗？删除后是不能恢复的！");
	if(qc == "0")
	{
		return false;
	}
	var url = base_url + base_func + "=del&id="+id;
	var msg = get_ajax(url);
	if(!msg) msg = "error!";
	if(msg == "ok")
	{
		window.location.href = window.location.href;
	}
	else
	{
		alert(msg);
		return false;
	}
}
function to_delete(id)
{
	if(!id)
	{
		alert("没有指定ID！");
		return false;
	}
	var qc = confirm("确定要删除该附件吗？删除后是不能恢复的！");
	if(qc == "0")
	{
		return false;
	}
	var url = base_url + base_func + "=del&id="+id;
	var msg = get_ajax(url);
	if(!msg) msg = "error!";
	if(msg == "ok")
	{
		window.location.href = window.location.href;
	}
	else
	{
		alert(msg);
		return false;
	}
}
function update_name(id)
{
	if(!id)
	{
		alert("获取ID错误！请检查！");
		return false;
	}
	var tname = getid("tmpname_"+id).value;
	if(!tname)
	{
		alert("名称不允许为空！");
		return false;
	}
	var url = base_url + base_func + "=update_name&id="+id+"&tmpname="+EncodeUtf8(tname);
	get_ajax(url,js_update_tmpname,id);
}
function js_update_tmpname(xmlhttp,id)
{
	var msg = ajax_result(xmlhttp);
	if(msg == "ok")
	{
		getid("notice_"+id).innerHTML = "更名成功";
		eval_js(3,"js_clear_tmpname("+id+")");
		return true;
	}
	else
	{
		if(msg)
		{
			getid("notice_"+id).innerHTML = msg;
			return false;
		}
	}
}
function js_clear_tmpname(id)
{
	getid("notice_"+id).innerHTML = "";
}
</script>
<!-- inc:footer -->